home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / LanRunner_2072176232007.psc / LanRunner Mini / clsICMPHeader.cls < prev    next >
Text File  |  2003-06-30  |  6KB  |  160 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsICMPProtocol"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. Private Type ICMPHeader
  17.     icmp_type               As Byte
  18.     icmp_code               As Byte
  19.     icmp_checksum           As Integer
  20.     icmp_ID                 As Long
  21. End Type
  22.  
  23.  
  24. Private m_icmp_type         As Byte
  25. Private m_icmp_code         As Byte
  26. Private m_icmp_checksum     As Long
  27. Private m_icmp_ID           As Long
  28.  
  29. Public ProtocolInterface    As clsProtocolInterface
  30.  
  31. Public Event RecievedPacket(IPHeader As clsIPHeader, ICMPProtocol As clsICMPProtocol)
  32.  
  33.  
  34. Public Sub PacketArrived(IPH As clsIPHeader, ReadBuffer() As Byte, BytesRecieved As Long)
  35.  
  36.   Dim ICMPH As ICMPHeader
  37.  
  38.     CopyMemory ICMPH, ByVal VarPtr(ReadBuffer(0)) + 20, LenB(ICMPH)
  39.  
  40.     Checksum = IntegerToUnsigned(ntohs(ICMPH.icmp_checksum))
  41.     Code = ICMPH.icmp_code
  42.     ID = ntohl(ICMPH.icmp_ID)
  43.     TheType = ICMPH.icmp_type
  44.  
  45.     RaiseEvent RecievedPacket(IPH, Me)
  46.     
  47. End Sub
  48.  
  49.  
  50.  
  51. Public Property Get TheType() As ICMPType
  52.     TheType = m_icmp_type
  53. End Property
  54.  
  55. Public Property Let TheType(val As ICMPType)
  56.     m_icmp_type = val
  57. End Property
  58.  
  59.  
  60. Public Property Get Code() As ICMPCodes
  61.     Code = m_icmp_code
  62. End Property
  63.  
  64. Public Property Let Code(val As ICMPCodes)
  65.     m_icmp_code = val
  66. End Property
  67.  
  68.  
  69. Public Property Get Checksum() As Long
  70.     Checksum = m_icmp_checksum
  71. End Property
  72.  
  73. Public Property Let Checksum(val As Long)
  74.     m_icmp_checksum = val
  75. End Property
  76.  
  77.  
  78. Public Property Get ID() As Long
  79.     ID = m_icmp_ID
  80. End Property
  81.  
  82. Public Property Let ID(val As Long)
  83.     m_icmp_ID = val
  84. End Property
  85.  
  86.  
  87. Public Function GetICMPCodeStr() As String
  88.  
  89.     Select Case m_icmp_type
  90.         Case ICMPType.[Destination Unreachable]
  91.             Select Case m_icmp_code
  92.                 Case ICMPCodes.[Network Unreachable]: GetICMPCodeStr = "Network Unreachable"
  93.                 Case ICMPCodes.[Host Unreachable]: GetICMPCodeStr = "Host Unreachable"
  94.                 Case ICMPCodes.[Protocol Unreachable]: GetICMPCodeStr = "Protocol Unreachable"
  95.                 Case ICMPCodes.[Port Unreachable]: GetICMPCodeStr = "Port Unreachable"
  96.                 Case ICMPCodes.[Fragmentation Needed]: GetICMPCodeStr = "Fragmentation Needed"
  97.             End Select
  98.         Case ICMPType.Redirect
  99.             Select Case m_icmp_code
  100.                 Case ICMPCodes.[Redirect Network]: GetICMPCodeStr = "Redirect Network"
  101.                 Case ICMPCodes.[Redirect Host]: GetICMPCodeStr = "Redirect Host"
  102.                 Case ICMPCodes.[Redirect TOS Network]: GetICMPCodeStr = "Redirect TOS Network"
  103.                 Case ICMPCodes.[Redirect TOS Host]: GetICMPCodeStr = "Redirect TOS Host"
  104.             End Select
  105.         Case ICMPType.[Time Exceeded]
  106.             Select Case m_icmp_code
  107.                 Case ICMPCodes.[TTL Exceeded In Transit]: GetICMPCodeStr = "TTL Exceeded In Transit"
  108.                 Case ICMPCodes.[Reassembly Timeout]: GetICMPCodeStr = "Reassembly Timeout"
  109.             End Select
  110.         Case ICMPType.[Parameter Problem]
  111.             Select Case m_icmp_code
  112.                 Case ICMPCodes.[Problem With Option]: GetICMPCodeStr = "Problem With Option"
  113.             End Select
  114.         Case Else
  115.             GetICMPCodeStr = "N/A"
  116.     End Select
  117.  
  118. End Function
  119.  
  120.  
  121.  
  122. Public Function GetICMPTypeStr() As String
  123.  
  124.     Select Case m_icmp_type
  125.         Case ICMPType.[Echo Reply]: GetICMPTypeStr = "Echo Reply"
  126.         Case 1, 2, 7: GetICMPTypeStr = "Reserved"
  127.         Case ICMPType.[Destination Unreachable]: GetICMPTypeStr = "Destination Unreachable"
  128.         Case ICMPType.[Source Quench]: GetICMPTypeStr = "Source Quench"
  129.         Case ICMPType.Redirect: GetICMPTypeStr = "Redirect"
  130.         Case ICMPType.[Alternate Host Address]: GetICMPTypeStr = "Alternate Host Address"
  131.         Case ICMPType.[Echo Request]: GetICMPTypeStr = "Echo Request"
  132.         Case ICMPType.[Router Advertisement]: GetICMPTypeStr = "Router Advertisement"
  133.         Case ICMPType.[Router Solicitation]: GetICMPTypeStr = "Router Solicitation"
  134.         Case ICMPType.[Time Exceeded]: GetICMPTypeStr = "Time Exceeded"
  135.         Case ICMPType.[Parameter Problem]: GetICMPTypeStr = "Parameter Problem"
  136.         Case ICMPType.[TimeStamp Reply]: GetICMPTypeStr = "Timestamp Request"
  137.         Case ICMPType.[TimeStamp Request]: GetICMPTypeStr = "Timestamp Reply"
  138.         Case ICMPType.[Information Request]: GetICMPTypeStr = "Information Request"
  139.         Case ICMPType.[Information Reply]: GetICMPTypeStr = "Information Reply"
  140.         Case ICMPType.[Address Mask Request]: GetICMPTypeStr = "Address Mask Request"
  141.         Case ICMPType.[Address Mask Reply]: GetICMPTypeStr = "Address Mask Reply"
  142.         Case 19: GetICMPTypeStr = "Reserved (security)"
  143.         Case 20, 21, 22, 23, 24, 25, 26, 27, 28, 29: GetICMPTypeStr = "Reserved (robustness experiment)"
  144.         Case ICMPType.[IP IX Trace Router]: GetICMPTypeStr = "TP IX Traceroute"
  145.         Case ICMPType.[Conversion Error]: GetICMPTypeStr = "Conversion Error"
  146.         Case ICMPType.[Mobile Host Redirect]: GetICMPTypeStr = "Mobile Host Redirect"
  147.         Case ICMPType.[IPv6 Where Are You]: GetICMPTypeStr = "IPv6 Where Are You"
  148.         Case ICMPType.[IPv6 Here I Am]: GetICMPTypeStr = "IPv6 I Am Here"
  149.         Case ICMPType.[Mobile Registration Request]: GetICMPTypeStr = "Mobile Registration Request"
  150.         Case ICMPType.[Mobile Registration Reply]: GetICMPTypeStr = "Mobile Registration Reply"
  151.         Case ICMPType.[Domain Name Request]: GetICMPTypeStr = "Domain Name Request"
  152.         Case ICMPType.[Domain Name Reply]: GetICMPTypeStr = "Domain Name Reply"
  153.         Case ICMPType.[SKIP Algorithm Discovery Protocol]: GetICMPTypeStr = "SKIP Algorithm Discovery_protocol"
  154.         Case ICMPType.[IPsec Security Failures]: GetICMPTypeStr = "IPsec Security Failures"
  155.         Case Is > 40: GetICMPTypeStr = "Reserved"
  156.     End Select
  157.  
  158. End Function
  159.  
  160.